package Hash;

public class Text {
    public static void main(String[] args) {
        Object locker2 = new Object();
        Object locker1 = new Object();
        Thread t1 = new Thread(() ->{

            synchronized (locker1){
               try {
                   Thread.sleep(1000);
               } catch (InterruptedException e) {
                   e.printStackTrace();
               }
                synchronized (locker2){
                   System.out.println("t1加锁成功");
               }
           }
        });
        Thread t2 = new Thread(() ->{
            synchronized (locker1){
                try {
                    Thread.sleep(1000);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
                synchronized (locker2){
                    System.out.println("t2加锁成功");
                }
            }
        });
        t1.start();
        t2.start();

    }
}
